var behalfMaterial = {
	behalfMaterialId: '',
	elderId: '',
	materialId: '',
	quantity: '',
	totalRent: '',
	payWay: '',
	createTime: '',
	updateTime: '',
	createId: getLoginedUser()? getLoginedUser().staffId: '',
	updateId: getLoginedUser()? getLoginedUser().staffId: '',
	subjectRoomId: getLoginedUser().subjectRoomId,
	subjectRoomName: getLoginedUser().subjectRoomName
};

var behalf_material_view = {
	data: behalfMaterial
};

var behalf_material_vue_vm = new Vue({
	el: '#behalf_material_vue_vm',
	data: behalf_material_view
});

function behalf_material_save() {
	if(isEmpty(elderBeHospital.isDetail) || elderBeHospital.isDetail=='no') {
		alert('请选择长者，并点击【确定】按钮');
		return;
	}
	
	if(getSelectedElderBeHospital) {
		var selectedElder = getSelectedElderBeHospital().elderForm;
		behalf_material_view.data.elderId = selectedElder.elderId;
		behalf_material_view.data.elderName = selectedElder.name;
	}
	
	//behalf_material_view.data.materialId = $('input:radio[name="materialId"]:checked').val();
	if(!behalf_material_view.data.materialId || behalf_material_view.data.materialId=='') {
		alert('请选择用品');
		return;
	}
	
	behalf_material_view.data.quantity = (behalf_material_view.data.quantity==''? 0: parseInt(behalf_material_view.data.quantity));
	if(!behalf_material_view.data.quantity || behalf_material_view.data.quantity==0) {
		alert('请输入数量');
		return;
	}
	
	behalf_material_view.data.totalRent = behalf_material_view.data.price * behalf_material_view.data.quantity;
	behalf_material_view.data.payWay = parseInt($('input:radio[name="payWay"]:checked').val());

	save_basic(path+'/behalfMaterial/save', {behalfMaterial:behalf_material_view.data}, function(behalfMaterialId) {
		alert('保存成功');
		var pageParam = behalf_material_view.data;
		pageParam.subjectRoomName = getLoginedUser()? getLoginedUser().subjectRoomName: '';
		pageParam.createName = getLoginedUser()? getLoginedUser().staffName: '';
		pageParam.buildingId = elderBeHospital.buildingId;
		pageParam.buildingName = elderBeHospital.buildingName;
		pageParam.floorId = elderBeHospital.floorId;
		pageParam.floorName = elderBeHospital.floorName;
		pageParam.roomNumber = elderBeHospital.roomNumber;
		pageParam.roomType = elderBeHospital.roomType;
		pageParam.bedNumber = elderBeHospital.bedNumber;
		
		window.open('6-2-4dgyongpin-1.html?pageParam=' + encodeURIComponent(JSON.stringify(pageParam)));
	});
}